﻿using System.Data;
using MySqlConnector;

namespace Front._1124;

public partial class BookMain : Form
{
    public BookMain()
    {
        InitializeComponent();
    }

    private void BookMain_Load(object sender, EventArgs e)
    {
        GetAllBooks();



        GetAllCategories();
    }

    private void GetAllBooks()
    {
        using var connection = new MySqlConnection("server=localhost;port=3306;user=root;password=root");
        connection.Open();
        string sql = "SELECT * FROM books_info;";
        MySqlDataAdapter adapter = new MySqlDataAdapter(sql, connection);
        DataSet dataSet = new DataSet();
        adapter.Fill(dataSet, "books_info");
        this.dataGridView1.DataSource = dataSet.Tables["books_info"];
    }

    private void GetAllCategories()
    {

    }
    private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
    }

    private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
    {
        if (result == DialogResult.OK)
        {
            int bookId = (int)this.dataGridView1.SelectedRows[0];
            
        }
    }
}